import request from '../utils/request'

// 获取文章列表
export function getArticleList(params: { page: number; limit: number; tag?: string }) {
  return request({
    url: '/article/list',
    method: 'get',
    params
  })
}

// 获取文章详情
export function getArticleDetail(id: string) {
  return request({
    url: `/article/${id}`,
    method: 'get'
  })
}

// 创建文章
export function createArticle(data: { 
  title: string; 
  content: string; 
  tags: string[]; 
  coverImage?: string 
}) {
  return request({
    url: '/article/create',
    method: 'post',
    data
  })
}

// 更新文章
export function updateArticle(id: string, data: { 
  title?: string; 
  content?: string; 
  tags?: string[]; 
  coverImage?: string 
}) {
  return request({
    url: `/article/${id}`,
    method: 'put',
    data
  })
}

// 删除文章
export function deleteArticle(id: string) {
  return request({
    url: `/article/${id}`,
    method: 'delete'
  })
} 